package test.orwapkg;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringProcessingEx {
	
	public static void main(String args[]){
		String str = "I am a student. I am preparing for OCPJP";
		
		System.out.println("index of: " + str.indexOf("am"));
		int fromIndex = str.indexOf("am");
		System.out.println("index of \"am\" from index: " + str.indexOf("am", fromIndex + 1));
		System.out.println(str.indexOf(0));
		
		System.out.println("region matches: " + str.regionMatches(7, "student", 0, 5));
		
		Integer parsedInt = Integer.parseInt("10"); 
		System.out.println(parsedInt.getClass());
		
		String strSplit = "Hello! My name is..";
		String strArray[] = strSplit.split(" ");
		
		for(String splits:strArray){
			System.out.println("splitted str: " + splits);
		}
		
		String path = "D:\\eclipse-jee-kepler-R-win32-x86_64\\eclipse";
		String loc[] = path.split("\\\\");
		for (String string : loc) {
			System.out.println(string);
		}
		
		String regExStr = "Danny Doo, Flat no 502, Big Apartment, Wide Road, Near Huge Milestone,Hugo-city 56010, "
						+ "Ph: 9876543210, Email: danny@myworld.com. Maggi Myer,Post bag no 52, "
						+ "Big bank post office, Big bank city 56000, ph: 9876501234, Email: maggi07@myuniverse.com.";
		
		Pattern pattern = Pattern.compile("[Danny]{1}");
		Matcher matcher = pattern.matcher(regExStr);
		if (matcher.find()) {
			System.out.println("\n***************  RegEx example ***********************");
			System.out.println(matcher.group());
		}
	}

}
